home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 1 / PC World Interactive 1 - Nisan 1997.iso / nostalji / bbs / music / sbbook.arj / SBBOOK / SOURCE / TP / PLAYVOCD.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-11-23  |  3.4 KB  |  117 lines

  1. (*********************************************************************
  2. *
  3. *  PROGRAM NAME: PLAYVOCD.PAS
  4. *
  5. *  COMPILER:     Borland Turbo Pascal ver. 4 or later
  6. *
  7. *  DESCRIPTION:  Plays a .VOC file from the disk using the CTVDSK.DRV
  8. *                double buffering driver (accessed from SBSIM).  To run
  9. *                the program, type the following at the command line:
  10. *
  11. *                PLAYVOCD FILENAME
  12. *
  13. *                Where FILENAME is the drive/path/filename of the .VOC
  14. *                file to play.
  15. *
  16. *  NOTE: SBSIM driver must be loaded before running this program.
  17. *
  18. *********************************************************************)
  19.  
  20. program playvocd;
  21. uses dos,crt;
  22.  
  23. const VOC_DSK_DRIVER = $02;
  24.  
  25.  
  26. {$I drvrfunc.pas}
  27.  
  28.  
  29. var Command:char;
  30.     UserQuit:boolean;
  31.     RetValue:simerr;
  32.     FileName:string;
  33.     FileHandle:integer;
  34.  
  35. (********************************************************************)
  36. begin (* main *)
  37.  
  38. if paramcount <> 1  (* no. of parameters entered on command line *)
  39. then begin
  40.      writeln('Command line must contain EXACTLY ONE filename parameter!');
  41.      halt;   (* Terminate program *)
  42.      end;
  43.  
  44. (*--- SEE IF SBSIM DRIVER HAS LOADED --*)
  45. SIMint := FindDvr('SBSIM', $0103);  (* Get SBSIM's interrupt no. *)
  46. if SIMint = 0
  47. then begin
  48.      writeln('SBSIM driver not loaded!');
  49.      halt;   (* Terminate program *)
  50.      end;
  51.  
  52. (*--- SEE IF CTVDSK.DRV DRIVER HAS LOADED -------*)
  53. if (GetDrvrs and VOC_DSK_DRIVER) <> VOC_DSK_DRIVER
  54. then begin
  55.      writeln('CTVDSK.DRV not loaded!');
  56.      halt;  (* Terminate program *)
  57.      end;
  58.  
  59.  
  60. (*--- LOAD THE FILE SPECIFIED ON COMMAND LINE (stored in argv[1]) ----*)
  61. FileHandle := DosOpen(paramstr(1), ReadAccess);
  62. if (FileHandle = -1)
  63. then begin
  64.      writeln('FILE: ',paramstr(1), ' not successfully opened!');
  65.      halt;    (* Terminate program *)
  66.      end;
  67.  
  68. DosClose(FileHandle);
  69.  
  70. FileName:=paramstr(1);  (* copy to string with more space before modifying *)
  71.  
  72. (*--- StartSnd() LOADS THE FILE AND INITIALIZES THE CTVDSKK.DRV DRIVER ---*)
  73. RetValue := StartSnd(DskVoice, AsciiZ(FileName), false, 0);
  74. if RetValue <> SIMerr_NoErr
  75. then begin
  76.      writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
  77.      halt;  (* Terminate program *)
  78.      end;
  79.  
  80. (*--- BEGIN PLAYING OF THE FILE -----------------------------------------*)
  81. RetValue := PlaySnd(DskVoice);
  82. if RetValue <> SIMerr_NoErr
  83. then begin
  84.      writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
  85.      halt;  (* Terminate program *)
  86.      end;
  87.  
  88. clrscr;  (* Clear screen *)
  89. writeln(#10#10#10#10#10'     SELECT ONE OF THE FOLLOWING OR WAIT UNTIL DONE:');
  90. writeln('                   (P)ause');
  91. writeln('                   (R)esume');
  92. writeln('                   (Q)uit');
  93.  
  94. UserQuit := false;
  95.  
  96. (*--- PROCESS USER INTERACTION OR WAIT FOR SOUND TO STOP -----------*)
  97. repeat
  98.      if (keypressed)  (* Was a key pressed? *)
  99.      then begin
  100.           Command := upcase(readkey);  (* Get char that's in buffer *)
  101.           if Command = 'P'
  102.           then PauseSnd(DskVoice)
  103.           else if Command = 'R'
  104.           then ResumeSnd(DskVoice)
  105.           else if Command = 'Q'
  106.           then UserQuit := true;
  107.           end;
  108. (* Exit do-while loop if file is done playing or user typed 'Q' *)
  109. until (UserQuit = true) or (GetSndStat(DskVoice) = 0);
  110.  
  111.  
  112. (*--- IF SOUND IS STILL PLAYING AND USER HIT 'Q', STOP THE SOUND ---*)
  113. if (GetSndStat(DskVoice) <> 0) and (UserQuit = true)
  114. then StopSnd(DskVoice);
  115.  
  116. end.
  117.